<!--
  ~ Copyright (c) 2020 the original author or authors
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  ~ or implied. See the License for the specific language governing
  ~ permissions and limitations under the License.
  -->

<div class="application-header">
  <app-spinner *ngIf="loading$ | async"></app-spinner>
  <mat-card class="application-header_left-coll">
    <div *ngIf="app$ | async as app">
      <h3 class="title">{{'applications.header.title' | translate}}</h3>
      <div class="name-wrapper">
        <div class="name-item" matTooltip="{{app.name}}" [matTooltipDisabled]="app.name.length <= maxHeaderLinkLength">
          {{app.name | truncate: maxHeaderLinkLength}}
        </div>
        <div *ngIf="userRole$ | async as userRole">
          <button *ngIf="userRole !== userRoleEnum.USER" mat-button type="button" color="primary" (click)="rename(app.name)">
            {{'applications.header.edit' | translate}}</button>
          <button *ngIf="userRole === userRoleEnum.OWNER" mat-button type="button" color="primary" (click)="delete(app.name)">
            {{'applications.header.delete' | translate}}</button>
        </div>
      </div>
    </div>
  </mat-card>
</div>
